<?php
namespace app\admin\model;
use think\Model;

class Order extends Model{
    public function searchKeywordsAttr($q,$v)
    {
        $q->where('u.name','like',"%{$v}%");
    }
    public function searchKtimeAttr($q,$v)
    {
        $q->where('o.addtime','>=',strtotime($v));

    }
    public function searchJtimeAttr($q,$v)
    {
        $q->where('o.addtime','<=',strtotime($v));
    }
    public function searchDPriceAttr($q,$v)
    {
        $q->where('price','<',$v);
    }
    public function searchGPriceAttr($q,$v)
    {
        $q->where('price','>',$v);
    }
    public function searchStatusAAttr($q,$v)
    {
        $q->where('status_a','in',$v);
    }
    public static function getOrder($where)
    {
        $list=self::withSearch(array_keys($where),$where)
            ->alias('o')
            ->field("o.*,u.uname,u.id,s.*")
            ->join('order_status s','o.status=status_id')
            ->join('user u','o.uid=u.id')
            ->paginate([
                'list_rows'=>5,
                'query'=>$where
            ]);
        return  $list;
    }
}